Skip to content

feat(config): add config unset to reset a setting to its default#301

Merged
jongio merged 2 commits into
mainfrom
idea/config-unset
Jul 14, 2026
Merged

feat(config): add config unset to reset a setting to its default#301
jongio merged 2 commits into
mainfrom
idea/config-unset

Conversation

@jongio

@jongio jongio commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Closes #296

Summary

Adds dispatch config unset <key> to reset a single setting to its default. Until now the only way to clear one key was to hand-edit the file or reset the whole config.

unset applies the value the key has in a freshly built default config and saves through the same path set uses, so validation and migrations still run. It reuses each field's validated setter, so it works the same for scalar, enum, duration, and the pointer-backed auto_refresh_seconds field (which resets to unset).

  • Unknown keys return the same "unknown config key" error as get and set.
  • No key, or more than one key, returns a clear usage error.
  • Shell completion (bash, zsh, powershell) lists unset, and the README documents it.

Note on the test change

Adding the config unset line to the help text pushed printUsage output past the Windows os.Pipe buffer, which made TestPrintUsage_Output deadlock: it drained the pipe only after printUsage returned, so the write blocked once the buffer filled. The test now drains the pipe from a goroutine, which is the portable fix and matches how the same capture pattern should work on any platform.

Verification

  • go build ./...
  • go test ./... (added tests for scalar reset, pointer-field reset, unknown key, both argument-count errors, and a save-error path)
  • go vet ./...
  • golangci-lint run --timeout 10m (0 issues)
  • mage deadcode (OK)

dispatch config could list, get, set, edit, and print the path, but the
only way to clear one setting back to its default was to edit the file
by hand or reset the whole config. Add config unset <key>, which applies
the value that key has in a freshly built default config and saves
through the normal path, so validation and migrations still run.

unset reuses each field's validated setter, so it works uniformly across
scalar, enum, duration, and the pointer-backed auto_refresh_seconds
field. Unknown keys and bad argument counts return the same style of
error as get and set. Shell completion lists unset and the README
documents it.

While adding the usage line for unset, the printUsage text crossed the
Windows os.Pipe buffer size, which made TestPrintUsage_Output deadlock
because it drained the pipe only after printUsage returned. The test now
drains the pipe from a goroutine so the write cannot block.

Closes #296

Co-authored-by: Copilot App <[email protected]>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 12, 2026
@jongio jongio self-assigned this Jul 12, 2026
@jongio jongio merged commit 9977fa5 into main Jul 14, 2026
2 checks passed
@jongio jongio deleted the idea/config-unset branch July 14, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dispatch config unset to reset a setting to its default

1 participant